<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<style>

      .layui-form  {
            padding: 10px  !important;
        }
      .layui-form-pane .layui-form-label
		.layui-upload-list img{
			height:100px;
			width:100px;
		}
      /*.layui-form-pane .layui-form-label{*/
      /*      width: 150px!important;*/
      /*  }*/

        .layui-textarea{
            width: 400px!important;
        }
	</style>
</head>
<body>
<!--内容开始-->
<section class="content">

    <!--数据表开始-->
    <div class="layui-form ok-form" name="form-builder">
        <!---->
        {if $form_items}
        <div class="row">
            <div class="col-sm-12 col-xs-12">
                <div class="box box-body">
                    <!---->
                    {volist name="form_items" id="form"}
                    {switch form.type}
                    	{case value="hidden"}
                            {// 隐藏域 }
                            {include file="form_builder/items/hidden" type='' /}
                        {/case}
                        {case text}
                        	{// 单行文本框 }
                        	{include file="form_builder/items/text" type='' /}
                        {/case}
                        {case number}
                        {// 单行文本框 }
                        {include file="form_builder/items/number" type='' /}
                        {/case}
                        {case value="textarea"}
                            {// 多行文本框 }
                            {include file="form_builder/items/textarea" type='' /}
                        {/case}
                        {case value="radio"}
                            {// 单选 }
                            {include file="form_builder/items/radio" type='' /}
                        {/case}
                        {case value="checkbox"}
                            {// 多选 }
                            {include file="form_builder/items/checkbox" type='' /}
                        {/case}

                        {case value="select"}
                            {// 下拉菜单 }
                            {include file="form_builder/items/select" type='' /}
                        {/case}


                        {default /}

                    {/switch}
                    {/volist}
                    <!---->
                    <div class="layui-form-item">
                            <div class="layui-input-block">
                            	{php}if(isset($btn_hide) && !in_array('submit', $btn_hide)):{/php}
                                <button class="layui-btn " lay-submit lay-filter="add">{$btn_title['submit']|default='提 交'}</button>
                                {php}endif;{/php}
                                {php}if(isset($btn_hide) && !in_array('back', $btn_hide)):{/php}

                                {php}endif;{/php}
                                {// 额外按钮}
                                {foreach $btn_extra as $key=>$vo }
                                {$vo|raw|default=''}
                                {/foreach}
                            </div>
                    </div>
                </div>
                <!-- /.box -->
            </div>
        </div>
        {else /}
        <div class="row">
            <div class="col-sm-12 col-xs-12">
                <div class="box box-body">
                    {$empty_tips|raw}
                </div>
                <!-- /.box -->
            </div>
        </div>
        {/if}
    </div>
</section>
<!--内容结束-->
<!--js逻辑-->
<script>
	layui.use(["element", "form", "laydate", "layer", "util"], function () {
		let form = layui.form;
		let laydate = layui.laydate;
		let layer = layui.layer;
		let $ = layui.jquery;
		//laydate.render({elem: "#birthday", type: "datetime"});
		form.verify({

		});
		form.render();
		form.on("submit(add)", function (data) {
			$.post("{$form_url}",  data.field,function (response) {
				if(response.code==1){
					layer.msg("编辑成功", function () {
						parent.layer.close(parent.layer.getFrameIndex(window.name));
					});
				}else{
                    layer.alert(response.msg, function () {

				    })
				}
			});

            return false; // 这段很关键

        });
	});
</script>
</body>
</html>
